package com.company.Dynamic;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.LinkedBlockingQueue;

public class KthMagicNumber {



    public int getKthMagicNumber(int k) {
        int[] key={3,5,7};
        List<Integer> collection=new ArrayList<>();
        Queue<Integer> queue = new LinkedBlockingQueue<>();
        queue.add(1);
        while (collection.size()<=k){
            Integer polled = queue.poll();
            if (!collection.contains(polled)) {
                collection.add(polled);
            }

            for (int i : key) {
                queue.add(polled*i);
            }
        }

        return collection.get(k-1);
    }
}
